package com.sanpu.kxe.business.main.view;

import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;

import com.sanpu.kxe.BuildConfig;
import com.sanpu.kxe.R;
import com.sanpu.kxe.base.BaseTitleActivity;
import com.sanpu.kxe.business.main.contract.SettingCenterContract;
import com.sanpu.kxe.business.main.presenter.SettingCenterPresenter;

import butterknife.Bind;
import butterknife.OnClick;

/**
 * Description：设置中心
 * Created by 薛勇军 on 2018/7/10.
 */

public class SettingCenterActivity extends BaseTitleActivity implements SettingCenterContract.View {

    @Bind(R.id.modif_ip)
    LinearLayout vModifIp;

    private SettingCenterContract.Presenter mPresenter;

    @Override
    protected int getLayoutResID() {
        return R.layout.activity_setting_center;
    }

    @Override
    protected void initView() {
        super.initView();
        commonTitle.setTitle("设置中心");
        if (BuildConfig.DEBUG) {
            vModifIp.setVisibility(View.VISIBLE);
        }
        mPresenter = new SettingCenterPresenter(this);
    }

    @OnClick({R.id.modif_login_password, R.id.modif_pay_password, R.id.out_login, R.id.modify_account, R.id.modif_ip})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.modif_login_password:
                mPresenter.openUpdateLoginPwdActivity();
                break;
            case R.id.modif_pay_password:
                mPresenter.openUpdatePayPwdActivity();
                break;
            case R.id.out_login:
                mPresenter.exitApp();
                break;
            case R.id.modify_account:
                mPresenter.openModifyAccountActivity();
                break;
            case R.id.modif_ip:
                mPresenter.openSettingHostActivity();
                break;
            default:
                break;
        }
    }

    @Override
    protected boolean hasBindEventBus() {
        return false;
    }

    @Override
    public void setPresenter(SettingCenterContract.Presenter presenter) {
        this.mPresenter = presenter;
    }

    @Override
    public Context getContext() {
        return this;
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mPresenter != null) {
            mPresenter.onDestroyPresenter();
            mPresenter = null;
        }
    }
}
